<!DOCTYPE html>
<html lang="zh">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
  <meta name="author" content="yinq">
  <title>站秀云服务管理系统-登录</title>
  <link rel="icon" href="./images/logo-ico.png">
  <meta name="author" content="张启全">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-touch-fullscreen" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="default">
  <link rel="stylesheet" type="text/css" href="css/materialdesignicons.min.css">
  <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
  <link rel="stylesheet" type="text/css" href="css/animate.min.css">
  <link rel="stylesheet" type="text/css" href="css/style.min.css">
  <link rel="stylesheet" type="text/css" href="js/layer/css/layui.css">
  <style>
  </style>
</head>

<body class="bg-white overflow-x-hidden">
<div class="row bg-white vh-100">
  <div class="col-md-6 col-lg-7 col-xl-8 d-none d-md-block" style="background-image: url(images/login-bg-1.jpg); background-size: cover;">

  </div>

  <div class="col-md-6 col-lg-5 col-xl-4 align-self-center">
    <div class="p-5">
      <div class="text-center">
        <a href="javascript:void(0)">站秀云服务管理系统</a>
      </div>
      <p class="text-center text-muted"><small>请使用您的账号登录系统</small></p>

      <form method="post" class="layui-form signin-form needs-validation" novalidate onsubmit="return false;">
        <div class="mb-3">
          <label for="username" style="margin-bottom: .5rem;">用户名</label>
          <input type="text" class="form-control" name="user_name" id="username" placeholder="请输入您的用户名" required>
        </div>

        <div class="mb-3">
          <label for="password" style="margin-bottom: .5rem;">密码</label>
          <input type="password" class="form-control" name="password" id="password" placeholder="请输入您的密码" required>
        </div>

        <div class="mb-3"  style="height: 5px;">
          <div class="form-check">

          </div>
        </div>

        <div class="mb-3 d-grid">
          <button class="btn btn-primary" lay-submit lay-filter="onsubmit" type="submit">立即登录</button>
        </div>
      </form>
    </div>
  </div>
</div>
<script type="text/javascript" src="js/layer/layui.js"></script>
<script>
  if(top.location!=self.location){
    parent.window.location=window.location.href;
  }
  ready(function(){
    layui.use(['zhanshop','form'], function(){
      var form = layui.form;
      var zhanshop = layui.zhanshop;
      form.on('submit(onsubmit)', function(data){
        var expiresDay = 1;
        if(data.field.expires_day) expiresDay = data.field.expires_day;
        data.field['_method'] = 'POST';
        zhanshop.ajax(API_ADDRESS+apiUrlLogin, 'POST', data.field, {}, function(res){
          if(res[apiCode] != 0){
            return zhanshop.alert(res[apiMsg], 'danger');
          }
          try{
            zhanshop.setcookie('token', res.data.token, 3600*24*10000);
            zhanshop.setcookie('the_header_bg', defaultBgcolor, 3600*24*10000);
            zhanshop.setcookie('the_logo_bg', defaultBgcolor, 3600*24*10000);
            for(var i in res.data){
              zhanshop.setSesson(i, res.data[i]);
            }
            // 存本地存储
            var referer = '';
            try{referer = window.atob(layui.zhanshop.getParam('referer'));}catch (e) {}
            // 如果不包含当前地址 只跳admin
            //ok 乱码后就无法出现?api
            if(referer && referer.lastIndexOf('/#/') >= 0){
              if(referer.lastIndexOf(window.location.protocol+'//'+window.location.hostname) >= 0){
                // 获取当前的网址
                return window.location = referer;
              }

            }

            window.location = 'index.html';
          }catch (e) {
            console.error(e);
            return zhanshop.alert('登录失败'+e.toString(), 'danger');
          }

        },function(xhr){
          return zhanshop.alert(xhr.responseJSON[apiMsg] ? xhr.responseJSON[apiMsg] : xhr.statusText, 'danger');
        });
        return false;
      });
    });

  });

</script>
</body>
</html>